/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.webhomesites.locacao.view;

import java.awt.Component;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import javax.swing.JTextField;

/**
 *
 * @author Webhome
 */
public class EmitirContratoView extends javax.swing.JDialog implements FocusListener {

    /**
     * Creates new form DevolucaoTotComPagView
     */
    public EmitirContratoView(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();     
        
        setLocationRelativeTo(null);
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        painelCentralDTCP = new javax.swing.JPanel();
        btnCancelar = new javax.swing.JButton();
        txtLocatario = new javax.swing.JTextField();
        btnModelo2 = new javax.swing.JButton();
        btnModelo1 = new javax.swing.JButton();
        btnModelo4 = new javax.swing.JButton();
        btnModelo3 = new javax.swing.JButton();
        labelLocatario = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        painelCentralDTCP.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Emitir Contrato", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, java.awt.Color.black));

        btnCancelar.setText("Cancelar");

        btnModelo2.setText("Modelo 2");

        btnModelo1.setText("Modelo 1");

        btnModelo4.setText("Modelo 4");

        btnModelo3.setText("Modelo 3");

        labelLocatario.setText("Nome de Locatário para sair no contrato");

        javax.swing.GroupLayout painelCentralDTCPLayout = new javax.swing.GroupLayout(painelCentralDTCP);
        painelCentralDTCP.setLayout(painelCentralDTCPLayout);
        painelCentralDTCPLayout.setHorizontalGroup(
            painelCentralDTCPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelCentralDTCPLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(painelCentralDTCPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(painelCentralDTCPLayout.createSequentialGroup()
                        .addComponent(txtLocatario)
                        .addContainerGap())
                    .addGroup(painelCentralDTCPLayout.createSequentialGroup()
                        .addGroup(painelCentralDTCPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelLocatario)
                            .addGroup(painelCentralDTCPLayout.createSequentialGroup()
                                .addComponent(btnModelo1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnModelo2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnModelo3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(painelCentralDTCPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(btnCancelar)
                                    .addComponent(btnModelo4))))
                        .addGap(0, 154, Short.MAX_VALUE))))
        );
        painelCentralDTCPLayout.setVerticalGroup(
            painelCentralDTCPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelCentralDTCPLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelLocatario)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtLocatario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(painelCentralDTCPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnModelo2, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnModelo4, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnModelo3, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnModelo1, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnCancelar)
                .addContainerGap(18, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(painelCentralDTCP, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(painelCentralDTCP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(EmitirContratoView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(EmitirContratoView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(EmitirContratoView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(EmitirContratoView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the dialog
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                EmitirContratoView dialog = new EmitirContratoView(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnModelo1;
    private javax.swing.JButton btnModelo2;
    private javax.swing.JButton btnModelo3;
    private javax.swing.JButton btnModelo4;
    private javax.swing.JLabel labelLocatario;
    private javax.swing.JPanel painelCentralDTCP;
    private javax.swing.JTextField txtLocatario;
    // End of variables declaration//GEN-END:variables

    

    
   


    
    public void packAndShow() {
        //ConfiguracaoInstancias.getDesktop().add(this);
//        try {
//            this.setSelected(true);
//            this.toFront();
//            this.moveToFront();
//        }
//        catch (PropertyVetoException ex) {
//            Logger.getLogger(DevolucaoTotComPagView.class.getName()).log(Level.SEVERE, null, ex);
//        }
// 
   
        
        this.pack();
        this.setVisible(true);
    }

    
    public void clearFields() {
        Component[] componentesPainel;
        componentesPainel = painelCentralDTCP.getComponents();
        for (int j = 0; j < componentesPainel.length; j++) {
            if (componentesPainel[j] instanceof JTextField) {
                JTextField field = (JTextField) componentesPainel[j];
                field.setText("");
            }
        }
    }   
    
    public void enableBtnModelo1(boolean arg) {
        btnModelo1.setEnabled(arg);
    }
    
    public void enableBtnModelo2(boolean arg) {
        btnModelo2.setEnabled(arg);
    }
    
    public void enableBtnModelo3(boolean arg) {
        btnModelo3.setEnabled(arg);
    }
    
    public void enableBtnModelo4(boolean arg) {
        btnModelo4.setEnabled(arg);
    }

    
    public void enableBtnCancelar(boolean arg) {
        btnCancelar.setEnabled(arg);
    }

    public void setModelo1ActionListener(ActionListener listener) {
        btnModelo1.addActionListener(listener);
    }
    
    public void setModelo2ActionListener(ActionListener listener) {
        btnModelo2.addActionListener(listener);
    }
    
    public void setModelo3ActionListener(ActionListener listener) {
        btnModelo3.addActionListener(listener);
    }
    
    public void setModelo4ActionListener(ActionListener listener) {
        btnModelo4.addActionListener(listener);
    }
    
    public void setCancelarActionListener(ActionListener listener) {
        btnCancelar.addActionListener(listener);
    }

    public void focusLost(FocusEvent e) {
        //throw new UnsupportedOperationException("Not supported yet.");
    }
    
    public void setLocatario(String locatario) {
        this.txtLocatario.setText(locatario);
    }

    
    public String getLocatario() {
        return this.txtLocatario.getText().equals("")?"1":this.txtLocatario.getText();
    }


    @Override
    public void focusGained(FocusEvent e) {
        //throw new UnsupportedOperationException("Not supported yet.");
    }
 
}

